/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Statistics.java
 *
 * Created on Mar 27, 2011, 9:23:11 PM
 */
package vn.aptech.project.view;

import vn.aptech.project.control.Employee_Detail_BLL;
import vn.aptech.project.control.category_BLL;
import vn.aptech.project.control.product_BLL;
import vn.aptech.project.control.tblorder_BLL;
import java.io.IOException;
import java.sql.SQLException;
import java.util.Vector;

/**
 *
 * @author Mr.Hiep
 */
public class Statistics extends javax.swing.JPanel {

    /** Creates new form Statistics */
    public Statistics() throws IOException, SQLException, ClassNotFoundException {
        initComponents();
        try {
            Employee_Detail_BLL edb = new Employee_Detail_BLL();
            product_BLL pb = new product_BLL();
            category_BLL cb = new category_BLL();
            tblorder_BLL tob = new tblorder_BLL();
            //-------Total Employee
            Vector vt1 = edb.totalemp();
            if (!vt1.isEmpty()) {
                String abc1 = vt1.toString();
                String TotalEmp = abc1.substring(2, abc1.length() - 2);
                lblSumNv.setText(TotalEmp);
            }
            //------Total Product
            Vector vt2 = pb.totalproduct();
            if (!vt2.isEmpty()) {
                String abc2 = vt2.toString();
                String TotalPro = abc2.substring(2, abc2.length() - 2);
                lblSumSp.setText(TotalPro);
            }
            //-----Top Category
            Vector vt3 = cb.topcategory();
            if (!vt3.isEmpty()) {
                String abc3 = vt3.toString();
                String TopCategory = abc3.substring(2, abc3.length() - 2);
                lblCt.setText(TopCategory);
            }
            //-----Total order
            Vector vt4 = tob.totalorder();
            if (!vt4.isEmpty()) {
                String abc4 = vt4.toString();
                String TotalOrder = abc4.substring(2, abc4.length() - 2);
                lblSumod.setText(TotalOrder);
            }
            //-----Top Order
            tblorder_BLL tob1 = new tblorder_BLL();
            Vector vt5 = tob1.toporder();
            if (!vt5.isEmpty()) {
                String abc5 = vt5.toString();
                String TopOrder = abc5.substring(2, abc5.length() - 2);
                lblTopod.setText(TopOrder);
            }
            //-----Top customer
            tblorder_BLL tob2 = new tblorder_BLL();
            Vector vt6 = tob2.topcustomer();
            if (!vt6.isEmpty()) {
                String abc6 = vt6.toString();
                String TopCustomer = abc6.substring(2, abc6.length() - 2);
                lblTopcs.setText(TopCustomer);
            }
            //-----Top product
            product_BLL pb1 = new product_BLL();
            Vector vt = pb1.top5product();
            if (!vt.isEmpty()) {
                String abc7 = vt.get(0).toString();
                String temm7 = abc7.substring(1, abc7.length() - 1);
                String[] arr = temm7.split(", ");
                lblname1.setText("+ " + arr[0] + " : " + arr[1]);
            }
            if (vt.size() > 1) {
                String abc8 = vt.get(1).toString();
                String temm8 = abc8.substring(1, abc8.length() - 1);
                String[] arr1 = temm8.split(", ");
                lblname2.setText("+ " + arr1[0] + " : " + arr1[1]);
            }
            if (vt.size() > 2) {
                String abc9 = vt.get(2).toString();
                String temm9 = abc9.substring(1, abc9.length() - 1);
                String[] arr2 = temm9.split(", ");
                lblname3.setText("+ " + arr2[0] + " : " + arr2[1]);
            }
            if (vt.size() > 3) {
                String abc10 = vt.get(3).toString();
                String temm10 = abc10.substring(1, abc10.length() - 1);
                String[] arr3 = temm10.split(", ");
                lblname4.setText("+ " + arr3[0] + " : " + arr3[1]);
            }
            if (vt.size() > 4) {
                String abc11 = vt.get(4).toString();
                String temm11 = abc11.substring(1, abc11.length() - 1);
                String[] arr4 = temm11.split(", ");
                lblname5.setText("+ " + arr4[0] + " : " + arr4[1]);
            }
        } catch (Exception ex) {
        }


    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        lblSumNv = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel4 = new javax.swing.JLabel();
        lblSumSp = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        lblname1 = new javax.swing.JLabel();
        lblname2 = new javax.swing.JLabel();
        lblname3 = new javax.swing.JLabel();
        lblname4 = new javax.swing.JLabel();
        lblname5 = new javax.swing.JLabel();
        lblCt = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        lblSumod = new javax.swing.JLabel();
        lblTopod = new javax.swing.JLabel();
        lblTopcs = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();

        setBackground(new java.awt.Color(255, 255, 255));
        setPreferredSize(new java.awt.Dimension(371, 304));
        setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel1.setText("Total employment :");
        add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 110, -1, -1));

        jLabel2.setText("Total products :");
        add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 140, -1, -1));

        lblSumNv.setText("0");
        add(lblSumNv, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 110, -1, -1));
        add(jSeparator1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 60, 540, 10));

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel4.setText("Statistics");
        add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 10, 310, 40));

        lblSumSp.setText("0");
        add(lblSumSp, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 140, -1, -1));

        jLabel6.setText("Top 5  product are bought at the most :");
        add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 180, -1, -1));
        add(lblname1, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 210, -1, -1));
        add(lblname2, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 240, -1, -1));
        add(lblname3, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 270, -1, -1));
        add(lblname4, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 300, -1, -1));
        add(lblname5, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 330, -1, -1));

        lblCt.setText("0");
        add(lblCt, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 360, -1, -1));

        jLabel14.setText("Category is ordered at the most :");
        add(jLabel14, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 360, -1, -1));

        lblSumod.setText("0");
        add(lblSumod, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 400, -1, -1));

        lblTopod.setText("0");
        add(lblTopod, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 420, -1, -1));

        lblTopcs.setText("Null");
        add(lblTopcs, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 440, -1, -1));

        jLabel18.setText("Total bill :");
        add(jLabel18, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 400, -1, -1));

        jLabel19.setText("Best bill :");
        add(jLabel19, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 420, -1, -1));

        jLabel20.setText("Best customer :");
        add(jLabel20, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 440, -1, -1));
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JLabel lblCt;
    private javax.swing.JLabel lblSumNv;
    private javax.swing.JLabel lblSumSp;
    private javax.swing.JLabel lblSumod;
    private javax.swing.JLabel lblTopcs;
    private javax.swing.JLabel lblTopod;
    private javax.swing.JLabel lblname1;
    private javax.swing.JLabel lblname2;
    private javax.swing.JLabel lblname3;
    private javax.swing.JLabel lblname4;
    private javax.swing.JLabel lblname5;
    // End of variables declaration//GEN-END:variables
}
